package com.example.hanchen.yongkanggy.utils;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;

import com.example.hanchen.yongkanggy.home.MyApplication;

public class BasicInformationUtils {
    // 获取手机型号
    public static String getPhoneModel() {
        String phoneModel = Build.MODEL;
        return phoneModel;
    }

    /*版本号获取*/
    public static int getVersionCode() {
        PackageInfo packageInfo = null;
        try {
            packageInfo = MyApplication.myApplication.getPackageManager().getPackageInfo(MyApplication.myApplication.getPackageName(), 0);
            int versionCode = packageInfo.versionCode;
            return versionCode;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return 0;
    }

    /*版本号名称*/
    public static String getVersionName() {
        try {
            PackageManager manager = MyApplication.myApplication.getPackageManager();
            PackageInfo info = manager.getPackageInfo(MyApplication.myApplication.getPackageName(), 0);
            String versionName = info.versionName;
            return versionName;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return "";
    }
}
